package ch.sv7.tool.dbmanager.db.conversion;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import ch.sv7.tool.dbmanager.db.ColumnSchema;
import ch.sv7.tool.dbmanager.db.dialect.CustomTypeConversion;

/**
 * TODO: Document me!
 *
 * @author svt
 *
 */
public class VarbinaryCustomTypeConversion implements CustomTypeConversion {

	public boolean convertType(ResultSet rs, String columnToRead, PreparedStatement updateStatement, int columnIndexToWrite, ColumnSchema fromColumn, ColumnSchema toColumn)
			throws SQLException {
		byte[] value = rs.getBytes(columnToRead);
		if (value != null) {
			updateStatement.setBytes(columnIndexToWrite, value);
			return true;
		} else {
			return false;
		}
		
	}

	/*
	public String getFromType() {
		return "varbinary";
	}

	public String getToType() {
		return "image";
	}
	*/
}
